function next (event) {

    if (!document.getElementById) return;
    if (window.event) event = window.event;

    if (event.ctrlKey) {
        var key = event.keyCode ? event.keyCode : event.which ? event.which : null;
        if (key == 0x27){
            document.location = $("#next-quote").attr("href");
        }
    }
}

$(document).ready(function(){

    $(document).keydown(next);

    /* font size */
    var quote = $("#quote");
	var length = $.trim(quote.text()).length;
    //console.log(length);
    if (length <= 50 && length > 30) {
        quote.css("font-size","35px");
    } else if (length <= 30) {
        quote.css("font-size","40px");
    } else if (length >= 70) {
        quote.css("font-size","20px");
    } else if (length >= 150) {
        quote.css("font-size","18px");
    }

    /* like */
    $("#like").on("click",function(){
        var like = $(this);
        $.ajax({
            url: "/like",
            data: "id="+$("#like_id").val(),
            type: "post",
            success: function(data){
                $("#rating").text(data);
                like.unbind("click").attr("id","liked");
            }
        })
    })
})